<template>
  <el-row>
    <el-col :span="24">
      <el-form :inline="true" :model="search" label-width="0px">
        <el-form-item prop="uid">
          <el-input v-model="search.uid" placeholder="用户名" clearable></el-input>
        </el-form-item>
        <el-form-item prop="nickName">
          <el-input v-model="search.nickName" placeholder="昵称" clearable></el-input>
        </el-form-item>
        <el-form-item prop="email">
          <el-input v-model="search.email" placeholder="邮箱" clearable></el-input>
        </el-form-item>
        <el-form-item prop="tel">
            <el-input v-model="search.tel" placeholder="电话" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button icon="Search" type="primary" @click="searchUser">搜索</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
  <el-row>
    <el-col :span="24">
      <el-table :data="userList" border stripe width="90%">
        <el-table-column prop="id" label="ID" width="100"></el-table-column>
        <el-table-column prop="uid" label="用户名"></el-table-column>
        <el-table-column prop="nickName" label="昵称"></el-table-column>
        <el-table-column prop="email" label="邮箱"></el-table-column>
        <el-table-column prop="tel" label="手机号"></el-table-column>
        <el-table-column prop="creatTime" label="注册时间"></el-table-column>
      </el-table>
    </el-col>
  </el-row>
</template>

<script setup>
import { inject, onMounted, reactive, ref } from 'vue'

const userList = ref([])
const search = reactive({})
const axios = inject('$axios')

onMounted(async () => {
  const res = await axios.get('/logic/sysuser/findByWhere')
  if (res.data.code === 200) {
    userList.value = res.data.data
  } else {
    alert(res.data.msg)
  }
})

const searchUser = async () => {
  const res = await axios.post('/logic/sysuser/findByWhere', search)
  if (res.data.code === 200) {
    userList.value = res.data.data
  } else {
    alert(res.data.msg)
  }
  console.info(res.data)
}
</script>

<style scoped>

</style>
